package demo1;

public class LogIn {

    private String userName = "admin";
    private String password = "123456";

    public  void loginInfo1(String userName, String password) {

        try {
            if (!this.userName.equals(userName)) {
                throw new UserNameErrorException("用户名错误！");
                //System.out.println("用户名错误！");
                //return;
            }
            if (!this.password.equals(password)) {
                throw new PassWorldException("密码错误！");
            /*System.out.println("密码错误！");
            return;*/
            }
            System.out.println("登陆成功");
        }catch (UserNameErrorException e) {
            //请重新输入密码  进行判断
            e.printStackTrace();
        }catch (PassWorldException e) {
            e.printStackTrace();
        }
    }
    public  void loginInfo(String userName, String password)
            throws UserNameErrorException,PassWorldException{

        if (!this.userName.equals(userName)) {
            throw new UserNameErrorException("用户名错误！");
            //System.out.println("用户名错误！");
            //return;
        }
        if (!this.password.equals(password)) {
            throw new PassWorldException("密码错误！");
        /*System.out.println("密码错误！");
        return;*/
        }
        System.out.println("登陆成功");

    }


    public static void main(String[] args) {
        try {
            LogIn logIn = new LogIn();
            logIn.loginInfo("admin2", "123456");
        }catch (UserNameErrorException e) {
            //请重新输入密码  进行判断
            e.printStackTrace();
        }catch (PassWorldException e) {
            e.printStackTrace();
        }
    }
}